import type { Configuration, Logger } from 'log4js';

// 日志级别类型
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';

// 日志上下文接口
export interface LogContext {
  [key: string]: unknown;
}

// 扩展的日志记录器接口
export interface CustomLogger extends Logger {
  trace(message: string, context?: LogContext): void;
  debug(message: string, context?: LogContext): void;
  info(message: string, context?: LogContext): void;
  warn(message: string, context?: LogContext): void;
  error(message: string, context?: LogContext): void;
  fatal(message: string, context?: LogContext): void;
}

// 日志配置接口
export interface LoggerConfig extends Configuration {
  appenders: {
    [name: string]: {
      type: string;
      filename?: string;
      pattern?: string;
      maxLogSize?: number;
      backups?: number;
      compress?: boolean;
      keepFileExt?: boolean;
      numBackups?: number;
      layout?: {
        type: string;
        pattern?: string;
      };
    };
  };
  categories: {
    [name: string]: {
      appenders: string[];
      level: LogLevel;
    };
  };
  pm2?: boolean;
  disableClustering?: boolean;
}
